************** THIS FILE MAKES TABLE 1 IN THE FINAL PAPER


use "${data}IndirectSurveyDataReplication.dta", clear
estimates clear

preserve
foreach x in tel_movil jefe_secondaria personas_hogar paredes_vivienda television  coche    num_reuniones  num_ganado_mayor cuidado_bosque {
rename `x'_a `x'_te
}
estpost sum *_te
estimates store A
restore
preserve
foreach x in tel_movil jefe_secondaria personas_hogar paredes_vivienda television  coche    num_reuniones  num_ganado_mayor cuidado_bosque {
rename `x'_hh_a `x'_te
}
estpost sum *_te
estimates store B
restore
* Normalized difference 
preserve
foreach x in tel_movil jefe_secondaria personas_hogar paredes_vivienda television  coche    num_reuniones  num_ganado_mayor cuidado_bosque {
ttest `x'_a = `x'_hh_a
gen `x'_te = (r(mu_2) - r(mu_1))/(sqrt(r(sd_2)^2 + r(sd_1)^2))
}

estpost sum  *_te
estimates store C


label variable paredes_vivienda_te "Has improved walls"
label variable coche_te "Has car"
label variable television_te "Has television"
label variable tel_movil_te "Has cell Phone"
label variable jefe_secondaria_te "Head has secondary education"
label variable cuidado_bosque_te "Participated in forest care"
label variable num_reuniones_te "\# of assembly meetings attended"
label variable personas_hogar_te "HH size"
label variable num_ganado_mayor_te "\# of large livestock owned"

esttab A B C using "${outputs}summaryvariables.tex", replace f cells("mean(fmt(3))" "sd(par fmt(3))" "b(fmt(3))" "se(par fmt(3))") ///
 label style (tex) noobs nonumbers starlevels(* 0.10 ** 0.05 *** 0.01) mlabels("" "" "" ) ///
nomtitles ///
collabels(none) prehead( \begin{tabular}{lccc}    ///
	 \hline \hline ///
	 & Leaders & Households & Norm Diff \\ ) ///
	  postfoot( \hline \hline \end{tabular} } \begin{tablenotes}[para,flushleft] \footnotesize{Table shows the variables measured in both the ///
	  direct and indirect surveys. Columns ///
	  (1) and (2) contain mean values of variables reported by leaders and households, respectively. Standard deviations are in parentheses below the ///
	  means. Column (3) lists the normalized difference of the two means. } \end{tablenotes} )
	

restore
estimates clear
******************* SIMPLE SUMMARY TABLE OF INDICES *****************************
preserve
reg PIB_leader PIB_HH
keep if e(sample)

foreach x in PIB IPW PCA {
rename `x'_leader `x'_temp 
}
estpost sum PIB_temp IPW_temp PCA_temp
estimates store A

foreach x in PIB IPW PCA {
rename `x'_temp `x'_leader
rename `x'_HH `x'_temp
}

estpost sum PIB_temp IPW_temp PCA_temp
estimates store B

foreach x in PIB IPW PCA {
rename `x'_temp `x'_HH
}

* Normalized difference 

foreach x in  PIB IPW PCA {
ttest `x'_leader = `x'_HH
gen `x'_temp = (r(mu_2) - r(mu_1))/(sqrt(r(sd_2)^2 + r(sd_1)^2))
}

estpost sum  PIB_temp IPW_temp PCA_temp
estimates store C


la var PIB_temp "Simple index (Simple)"
la var IPW_temp "Inverse proportion weighted index (IPW)"
la var PCA_temp "Principle components index (PCA)"

esttab A B C using "${outputs}summaryindexes.tex", replace  ///
cells("mean(fmt(3))" "sd(par fmt(3))" "b(fmt(3))" "se(par fmt(3))") style (tex) fragment ///
collabels(none) mtitle(none) nonumbers starlevels(* 0.10 ** 0.05 *** 0.01) label mlabels("" "" "" )  ///
prehead( \begin{tabular}{lccc}    ///
	 \hline \hline ///
	 & Leaders & Households & Norm Diff \\ ) ///
	  postfoot( \hline \hline \end{tabular} } \begin{tablenotes}[para,flushleft] \footnotesize{Table shows the constructed indices. Columns ///
	  (1) and (2) contain mean values of variables reported by leaders and households, respectively. Standard deviations are in parentheses below the ///
	  means. Column (3) lists the normalized difference of the two means. } \end{tablenotes} )
estimates clear

restore

